"""站内信页面"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from config.config import HOST
class InSiteMessage(BasePage):
    """数据准备"""
    url=HOST+r"/index.php?m=message"
    #定位器
    click_wal_locator = (By.LINK_TEXT, "写信")
    click_one_recipient_locator = (By.CSS_SELECTOR, "#ta1 > span:nth-child(3) > input")
    content_locator = (By.NAME, "content")
    click_save_locator = (By.NAME, "submit")
    clean_up_the_environment_locator=(By.CSS_SELECTOR,"#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input")
    btn_letter = (By.CSS_SELECTOR,"body > div.container > div.row > div > div.span12.nav > div > ul > li.nav.pull-left > div > a")
    delet_locator=(By.ID,"delete_receive")
    currently_add_result_locator=(By.CSS_SELECTOR,"body > div.container > div.alert.alert-success")
    def click_wal(self):
        """点击写信"""
        self.click(self.click_wal_locator)
    def btn_recipient(self):
        """选择第一个收件人"""
        self.click(self.click_one_recipient_locator)
    def content(self,content):
        """编辑内容"""
        self.send_keys(self.content_locator,content)
    def click_save(self):
        """点击保存"""
        self.click(self.click_save_locator)
    def currently_add_result(self):
        """实际添加结果文本"""
        return self.find_element(self.currently_add_result_locator).text
    def clean_up_the_environment(self):
        """清理环境"""
        self.click(self.clean_up_the_environment_locator)
        self.click(self.btn_letter)
        self.click(self.delet_locator)
        self.driver.switch_to.alert.accept()
    def click_one_data(self):
        """选择第一条数据"""
        self.click(self.clean_up_the_environment_locator)
    def click_operation(self):
        """点击批量操作"""
        self.click(self.btn_letter)
    def click_delete(self):
        """点击批量删除"""
        self.click(self.delet_locator)
    def click_sure(self):
        """弹出弹窗点击确定"""
        self.driver.switch_to.alert.accept()

